Controller, information processing apparatus, and recording medium

ABSTRACT

A technique capable of efficiently performing debugging in a program and checking of soundness in a control system including a controller and a database system. A CPU unit has a communication interface for connection to a database device. The CPU unit executes a user program to call a DB connection service in accordance with an instruction included in the user program and generate a statement to access the database device. In the DB connection service, a statement according to an access instruction is generated, and the generated statement is transmitted to a database system. After that, information indicative of time until a response from the database system is received is acquired, and the acquired information is stored as a log into a memory. A support device acquires the information and displays it on a monitor.

BACKGROUND OF THE INVENTION

1. Technical Field

The present invention relates to a control system including a controllerwhich executes a user program periodically, and more particularly, to acontrol system which is connected to a database system.

2. Related Art

Machinery and equipment used in many production sites are typicallycontrolled by a control system including, as a main component, acontroller such as a programmable logic controller (hereinbelow, alsocalled “PLC”). In such a control system, various log output functionsare installed so that a failure which occurs at the time of constructingthe system or during operation can be examined ex-post facto.

As prior art Documents related to the controller having such functions,Japanese Unexamined Patent Publication No. 2012-208932 discloses a PLCsystem including a PLC controlling operation of a device and aprogrammable display device connected to the PLC via a communicationline. In the PLC system, the PLC includes an information storage whichstores state information corresponding to the predetermined operationstate in information stored in the information storage, into apredetermined storing unit, when a predetermined operation state of thedevice is detected.

In recent years, a control system in which a PLC is connected to adatabase system and data held in the PLC is stored in the databasesystem is also known. In such a control system, when the PLC accessesthe database system, there is a case that a process is required to becompleted within predetermined time. For example, in the case where acontrol system is used in a process of production or test in a factoryor the like, data which is sequentially generated has to be processedwithin proper time. Due to occurrence of a failure or inconvenience,there is a case that the process time as the performance of the controlsystem becomes longer than process time assumed by a designer and thelike. In this case, the designer, the administrator of the controlsystem, and the like have to analyze the cause and take a measure. As ameasure, for example, there is a case that the speed of the controlprocess of a controller has to be increased or a case that the responseperformance of the database system has to be improved.

Therefore, also in the case where an inconvenience such as a delayoccurs in a process of a control system including a controller and adatabase system, a technique for facilitating analysis of the cause ofthe inconvenience is needed.

SUMMARY

A controller according to an aspect of the present invention includes: acommunication interface configured to be connected to a database system;an instruction executing unit configured to execute a user program forcontrolling a control object; and an access processing unit, at the timeof executing the user program including an access instruction to accessthe database system by the instruction executing unit, configured tocontrol an access to the database system via the communicationinterface, wherein the access processing unit includes: a statementtransmitting unit configured to generate a statement according to theaccess instruction and transmit the generated statement to the databasesystem; and an acquiring unit configured to store into a memoryinformation indicative of time since transmission of the generatedstatement to the database system until reception of a response from thedatabase system.

Preferably, the acquiring unit starts measurement of response time bytransmitting the generated statement to the database system and storesinto the memory the information indicative of a result of themeasurement of the response time since transmission of the statement tothe database system until reception of a response from the databasesystem.

Preferably, the acquiring unit records transmission time at which thegenerated statement is transmitted to the database system, recordsreception time at which a response from the database system to thestatement is received, acquires information indicative of time until aresponse from the database system is received on the basis of thetransmission time and the reception time, and stores the acquiredinformation into the memory.

Preferably, in the case where a normal response is received from thedatabase system after the statement is transmitted to the databasesystem, the acquiring unit stores the response time into the memory.

Preferably, the instruction executing unit executes a user programincluding a status acquisition instruction for acquiring informationindicative of time until a response from the database system isreceived, and the access processing unit sends the information stored inthe memory to the user program in response to the status acquisitioninstruction.

Preferably, the controller further includes an information processingapparatus connected to the controller; and an input/output unitconfigured to transmit and receive data, wherein the acquiring unitacquires information indicative of time until the response is receivedin association with time information each time the statement istransmitted to the database system, and the input/output unit transmitsto the information processing apparatus the time information and theinformation indicative of time until the response is received, inassociation with each other.

An information processing apparatus according to an aspect of thepresent invention is connected to a controller, wherein the controlleris connected to a database system and includes: a statement transmittingunit configured to, at the time of executing a user program including anaccess instruction for accessing the database system, generate astatement according to the access instruction, and transmit thegenerated statement to the database system; and an acquiring unitconfigured to store into a memory time information indicative of timesince the transmission of the generated statement to the database systemby the statement transmitting unit until reception of a response fromthe database system, and the information processing apparatus includes:a reception processing unit configured to receive the time informationstored in the memory by the acquiring unit from the controller; and adisplay processing unit configured to display the time informationreceived by the reception processing unit on a monitor.

Preferably, each time the statement is transmitted to the databasesystem, the acquiring unit of the controller stores into the memoryinformation indicative of time until the response is received, inassociation with time information, the reception processing unit of theinformation processing apparatus receives from the controllerinformation indicative of time until the response associated with thetime information is received, and the display processing unit displaysthe received time information in association with the time information.

A program according to an aspect of the present invention is configuredto control operation of a controller, wherein the controller includes acommunication interface configured to access a database system, aprocessor, and a memory, and the program causes the processor toexecute: a step of executing a user program to control a control object;a step of, at the time of executing the user program including an accessinstruction to access the database system, generating a statementaccording to the access instruction and transmitting the generatedstatement to the database system via the communication interface; a stepof storing into the memory information indicative of time sincetransmission of the generated statement to the database system untilreception of a response from the database system; and a step ofoutputting the stored information to the information processingapparatus connected to the controller.

A controller according to an aspect of the present invention includes: acommunication interface configured to be connected to a database system;a processor; and a memory, wherein the processor executes a user programto control a control object, at the time of executing an accessinstruction to access the database system that is included in the userprogram, generates a statement according to the access instruction,transmits the generated statement to the database system via thecommunication interface, and stores into the memory informationindicative of time until reception of a response from the databasesystem since the transmission.

According to the present invention, debugging of a program and checkingof soundness can be performed efficiently. For example, even in the casewhere an inconvenience such as a delay occurs in a process of a controlsystem including a controller and a database system, analysis of thecause can be easily performed.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram illustrating the configuration of acontrol system according to an embodiment;

FIG. 2 is a schematic diagram illustrating a hardware configuration of amain part of a PLC according to the embodiment;

FIG. 3 is a schematic diagram illustrating a software configuration ofthe PLC according to the embodiment;

FIG. 4 is a schematic diagram illustrating a hardware configuration of asupport device used by being connected to the PLC according to theembodiment;

FIG. 5 is a schematic diagram for explaining the outline of a log outputfunction provided by the control system according to the embodiment;

FIG. 6 is a diagram illustrating an operation log;

FIG. 7 is a flowchart illustrating the procedure in the PLC in theembodiment and the procedure of a database device;

FIG. 8 is a diagram illustrating the procedure taken when an instructiontimeout occurs and the procedure of the database device;

FIG. 9 is a flowchart illustrating the procedure of the PLC in amodification and the procedure of the database device;

FIG. 10 is a flowchart illustrating a process to obtain DB response timeof the support device;

FIG. 11 is a diagram illustrating an example of a user interface in thecase of displaying the operation log including DB response time in thesupport device; and

FIG. 12 is a diagram illustrating an example of a user interfaceprovided in the support device in the embodiment.

DETAILED DESCRIPTION

Embodiments of the present invention will be described in detail withreference to the drawings. The same reference numerals are designated tothe same or corresponding parts in the diagram and their descriptionwill not be repeated.

A. System Configuration

First, the configuration of a control system according to the embodimentwill be described. In the embodiment, a programmable controller (PLC)controlling a control object such as machinery or equipment will bedescribed as a typical example of a controller. The controller accordingto the present invention is not limited to a PLC but can be applied tovarious controllers.

FIG. 1 is a schematic diagram illustrating the configuration of acontrol system 1 according to an embodiment. Referring to FIG. 1, thecontrol system 1 includes a PLC 100, a support device 300 connected tothe PLC 100, and a database device 400 receiving an access from the PLC100. The PLC 100 executes a user program as will be described laterperiodically or as an event. The user program is generated by the userof the PLC 100. The user can generate, for example, a program (sourceprogram) including an access instruction by operating the support device300. The support device 300 converts the source program to a form whichcan be executed in the PLC 100 and transmits the converted user programto the PLC 100. The PLC 100 executes the user program and can access thedatabase device 400 in accordance with the access instruction includedin the user program.

That is, the PLC 100 and the database device 400 are constructed so thatdata can be transmitted/received to/from each other via a network 112such as the Ethernet (registered trademark).

The support device 300 is a typical example of an information processingdevice which can be connected to the PLC 100. The support device 300 isconnected to the PLC 100 via a connection cable 114, and providesfunctions such as settings of various parameters, programming,monitoring, debugging, and the like to the PLC 100. The PLC 100 and thesupport device 300 can typically perform communication each other inaccordance with the USB (Universal Serial Bus) standard.

The PLC 100 includes a CPU unit 104 executing a control operation and atleast one IO (Input/Output) unit 106. Those units are constructed so asto transmit/receive data each other via a PLC system bus 108. To thoseunits, power of proper voltage is supplied by a power supply unit 102.

In the control system 1, the PLC 100 transmits/receives data to/fromvarious field devices via the IO unit 106 (connected via the PLC systembus 108) and/or a field bus 110. The field devices include an actuatorfor performing some processes on a control object and a sensor forobtaining various pieces of information from a control object. In FIG.1, as an example of such field devices, the control system 1 includes adetection switch 10, a relay 20, and a servo motor driver 30 driving amotor 32. To the PLC 100, a remote IO terminal 200 is connected via thefield bus 110. The remote IO terminal 200 basically performs processesrelated to a general input/output process in a manner similar to the IOunit 106. More concretely, the remote IO terminal 200 includes acommunication coupler 202 for performing a process related to datatransmission in the field bus 110 and at least one IO unit 204. Thoseunits are constructed so as to transmit/receive data from one anothervia a remote IO terminal bus 208.

B. Configuration of PLC 100

Next, the configuration of the PLC 100 according to the embodiment willbe described. FIG. 2 is a schematic diagram illustrating a hardwareconfiguration illustrating a main part of the PLC 100 according to theembodiment. FIG. 3 is a schematic diagram illustrating a softwareconfiguration of the PLC 100 according to the embodiment.

With reference to FIG. 2, the hardware configuration of the CPU unit 104of the PLC 100 will be described. The CPU unit 104 includes a processor120, a chip set 122, a system clock 124, a main memory 126, anonvolatile memory 128, a USB connector 130, a PLC system bus controller140, a field bus controller 150, a high-order communication controller160, and a memory card interface 170. The chip set 122 and the othercomponents are coupled to one another via various buses.

The processor 120 and the chip set 122 are constructed typically inaccordance with a general computer architecture. That is, the processor120 interprets and executes instruction codes which are sequentiallysupplied in accordance with internal clocks from the chip set 122. Thechip set 122 transmits/receives internal data to/from the variouscomponents that are being connected and generates an instruction codenecessary for the processor 120. The system clock 124 generates a systemclock in a predetermined cycle and provides it to the processor 120. Thechip set 122 has a function of caching data obtained as a result ofexecution of an arithmetic process in the processor 120 or the like.

The CPU unit 104 has, as storing means, the main memory 126 and thenonvolatile memory 128. The main memory 126 is a volatile storageregion, holds various programs to be executed by the processor 120, andis also used as a work memory when the various programs are executed.The nonvolatile memory 128 holds an OS (Operating System), a systemprogram, a user program, log information, and the like in a nonvolatilemanner.

The USB connector 130 is an interface for connecting the support device300 and the CPU unit 104. Typically, an executable program which istransferred from the support device 300 and the like is loaded in theCPU unit 104 via the USB connector 130.

The CPU unit 104 has, as communication means, the PLC system buscontroller 140, the field bus controller 150, and the high-ordercommunication controller 160. Those communication circuits transmit andreceive data.

The PLC system bus controller 140 controls transmission/reception ofdata via the PLC system bus 108. More concretely, the PLC system buscontroller 140 includes a buffer memory 142, a PLC system bus controlcircuit 144, and a DMA (Dynamic Memory Access) control circuit 146. ThePLC system bus controller 140 is connected to the PLC system bus 108 viaa PLC system bus connector 148.

The field bus controller 150 includes a buffer memory 152, a field buscontrol circuit 154, and a DMA control circuit 156. The field buscontroller 150 is connected to the field bus 110 via a field busconnector 158. The high-order communication controller 160 includes abuffer memory 162, a high-order communication control circuit 164, and aDMA control circuit 166. The high-order communication controller 160 isconnected to the network 112 via a high-order communication connector168.

A memory card interface 170 connects the processor 120 and a memory card172 which can be detachably connected to the CPU unit 104.

Referring now to FIG. 3, a software configuration for realizing variousfunctions provided by the PLC 100 according to the embodiment will bedescribed. An instruction code included in the software is read at aproper timing and executed by the processor 120 of the CPU unit 104.

In FIG. 3, software executed in the CPU unit 104 is an OS 180, a systemprogram 188, and a user program 186.

The OS 180 provide basic execution environment for the processor 120 toexecute the system program 188 and the user program 186.

The system program 188 is a software group for providing basic functionsof the PLC 100. Concretely, the system program 188 includes a sequenceinstruction program 190, a DB (database) access process program 192, aninput/output process program 194, a tool interface process program 196,and a scheduler 198.

The user program 186 is a program arbitrarily generated according to acontrol purpose for a control object. That is, the user program 186 isarbitrarily designed in accordance with an object to be controlled byusing the control system 1.

The user program 186 realizes a control purpose of the user incooperation with the sequence instruction program 190. That is, the userprogram 186 realizes a programmed operation by using an instruction, afunction, a function module, or the like provided by the sequenceinstruction program 190. Therefore, the user program 186 and thesequence instruction program 190 will be also collectively called“control programs”.

In the operation log 184, when a predetermined event occurs accompanyingexecution of the system program 188 and the user program 186,information of the occurred event is stored in association with timeinformation. That is, in the operation log 184, various pieces ofinformation accompanying execution of the system program 188 and/or theuser program 186 is stored as a log (history information). DB responsetime 184J is a log recorded by a process which will be described laterand is a log of response time when the PLC 100 performs communicationwith the database device 400. In the embodiment, the PLC 100 records, asthe DB response time 184J, time since the PLC 100 transmits a statementto the database device 400 to the database device 400 until a responseis received, into the operation log 184.

Hereinafter, each of the programs will be described more specifically.

The sequence instruction program 190 includes an instruction code group,accompanying execution of the user program 186, for calling entity of asequence instruction designated in the user program 186 and realizingthe instruction.

The DB access process program 192 includes an instruction code group forrealizing a process necessary to access the database device 400,accompanying execution of the user program 186. The DB access processprogram 192 includes an execution code corresponding to a designableinstruction in the user program 186.

The input/output process program 194 is a program for managingacquisition of input data and transmission of output data from/to the IOunit 106 and the various field devices.

The tool interface process program 196 provides an interface fortransmitting/receiving data to/from the support device 300.

The scheduler 198 generates a thread and a procedure for executing acontrol program in accordance with a predetermined priority, the valueof a system timer, and the like.

As described above, the user program 186 is generated according to acontrol purpose of the user. The user program 186 typically is of anobject program form which can be executed by the processor 120 of theCPU unit 104. The user program 186 is generated when a source programdescribed in a ladder form or a function block form is compiled in thesupport device 300. The generated user program in the object programformat is transferred from the support device 300 to the CPU unit 104and stored in the nonvolatile memory 128 or the like.

The PLC 100 has the configuration described by using FIGS. 2 and 3 andfunctions as “an instruction executing unit for executing a user programfor controlling a control object” when the processor 120 executes thesystem program 188 and the user program 186. The PLC 100 functions as“an access processing unit for controlling an access to the databasedevice 400 via the communication interface at the time of execution ofthe user program including an access instruction to access the databasedevice 400 by the instruction executing unit” when the processor 120executes the DB access process program 192 and the user program 186.When the processor 120 executes the DB access process program 192 inaccordance with an access instruction included in the user program 186,the PLC 100 functions as “a statement transmitting unit for generating astatement (SQL statement) according to the access instruction andtransmitting the generated statement to the database device 400” and “anacquiring unit for storing, into a memory, information indicative oftime since the generated statement is transmitted to the database device400 until a response from the database device 400 is received”.

C. Configuration of Support Device 300

Next, the support device 300 according to the embodiment will bedescribed. The support device 300 is to support use of the CPU unit 104of the PLC 100 and provides functions of setting various parameters,programming, monitoring, debugging, and the like for the PLC 100.

FIG. 4 is a schematic diagram illustrating a hardware configuration ofthe support device 300 used by being connected to the PLC 100 accordingto the embodiment. The support device 300 is typically constructed by ageneral computer.

Referring to FIG. 4, the support device 300 includes a CPU 302 executingvarious programs including an OS, a ROM (Read Only Memory) 304 storingBIOS and various pieces of data, a memory RAM 306 providing a work areafor storing data necessary to execute a program in the CPU 302, and ahard disk (HDD) 308 storing a program or the like executed by the CPU302 in a nonvolatile manner. More concretely, in the hard disk 308, asupport program 330 for realizing the functions provided by the supportdevice 300 is stored.

The support device 300 also includes a keyboard 310 and a mouse 312accepting an operation from the user, and a monitor 314 for providinginformation to the user. Further, the support device 300 includes acommunication interface (IF) 318 for communication with the PLC 100 (CPUunit 104) and the like.

The support program 330 and the like executed by the support device 300are stored in an optical recording medium 332 and distributed. A programstored in the optical recording medium 332 is read by an optical diskreading device 316 and stored in the hard disk 308 or the like.Alternatively, a program may be downloaded from a high-order hostcomputer or the like via a network.

When the support device 300 is connected to the PLC 100 via thecommunication IF 318 and the CPU 302 executes the support program 330,the support device 300 displays the function of “a reception processingunit of receiving from the PLC 100 the operation log 184 including theDB response time 184J stored in the memory of the PLC 100” and a“display processing unit of displaying the operation log 184 includingthe DB response time 184J received by the reception processing unit tothe monitor 314”.

D. Configuration of Database Device 400

Next, the database device 400 according to the embodiment will bedescribed. As the database device 400, a known configuration providing adatabase can be employed. As such a database, an arbitrary configurationof a relational data type or an object data type can be employed. Sincethe database device 400 is constructed according to a general computerarchitecture, its detailed description will not be repeated here.

The database device 400 receives a connection request or an accessrequest (an SQL statement in a relational data type) from the PLC 100,executes a necessary process, and sends the process result or the likeas a response to the PLC 100.

E. Outline of Storage of Log of DB (Database) Response Time

Next, outline of the log output function provided by the control system1 according to the embodiment will be described. The log output functionaccording to the embodiment can output a log which is outputaccompanying execution of a predetermined process determined by aprogram (hereinbelow, also called “execution log”) and a log which isoutput accompanying occurrence of a failure in execution of a program ora failure in hardware (hereinbelow, also called “event log”). Theoperation log 184 includes all of those logs. In the embodiment, asdescribed above, time since the PLC 100 transmits a statement to thedatabase device 400 until a response is received is recorded as the DBresponse time 184J in the operation log 184. In the embodiment, anexample that the PLC 100 writes the operation log 184 to a recordingmedium such as a memory card loaded to the PLC 100 will be described. Ina recording medium such as a memory card, the operation log 184 isstored as a log file.

The execution log is information obtained by recording a process of apredetermined kind which is executed, in association with timeinformation. By the execution log, execution of a process designated inthe user program 186 can be recognized. Basically, the execution log isalways logged during operation of the PLC 100 (a state where a processof a predetermined kind is executed by a program). An event log isinformation of a designated process recorded in association with timeinformation in the case such that execution of the process fails.Typically, in the case such that a designated process is interrupted dueto an error or the like, the process is logged.

FIG. 5 is a schematic diagram for explaining the outline of a log outputfunction provided by the control system 1 according to the embodiment.In the example of FIG. 5, the user generates a program including aninstruction of connection to the database device 400 by a supportprogram executed by the support device 300. The support device 300converts a generated program to a format which can be executed by thePLC 100 and transmits the converted user program from the support device300 to the PLC 100. An instruction defined by the user program 186 canbe arbitrarily defined, and the kind of the defined instruction does notexert any influence on the scope of the present invention.

More concretely, it is assumed that the user operates the support device300 to generate a program so that a DB connection instruction(DB_Insert) is included in the user program 186. The user programgenerated by the support device 300 is executed by the PLC 100, and atthe timing of executing the DB connection instruction, a correspondinginstruction code in the DB access process program 192 (FIG. 3) iscalled, and an SQL statement including the request of connection to thedatabase device 400 is generated and transmitted. That is, the DBconnection service realized by the DB access process program 192included in the system program 188 is provided, and a DB connectionservice is triggered by issuance of the DB connection instruction in theuser program 186. By the DB connection service, an SQL statement isgenerated and the generated SQL statement is transferred to a DB accessfunction. The DB access function is driver software used to accessvarious database systems. The DB access function is a function realizedby the high-order communication controller 160 (FIG. 2) and the DBaccess process program 192 (FIG. 3), and transmits the SQL statementreceived from the DB connection service to the database device 400 viathe network 112.

The database device 400 receives the SQL statement from the PLC 100,executes the process in accordance with the SQL statement, and asnecessary, sends the result of the process as a response to the PLC 100.

In the DB connection service, in response to execution of the DBconnection instruction (generation and transmission of the SQLstatement), the information designated by the instruction is written inassociation with time information (that is, as an execution log) intothe operation log 184 (in the example of FIG. 5, a log file 1842 storedin the memory card 172). That is, the log of the operation state of thePLC 100 is stored. At this time, the user does not have to explicitlyinstruct writing of the execution log to the operation log 184. A systemenvironment is constructed such that when the DB connection instructionis executed, the DB connection service automatically writes theoperation state to the operation log 184.

That is, the CPU unit 104 of the PLC 100 functions as writing meanswhich, in response to occurrence of a predetermined event, by executingthe DB access process program 192 (system program 188), writesinformation of the occurred event (execution log and/or event log) inassociation with time information into the memory card 172 serving as astorage. At this time, by executing the system program 188 preliminarilystored in the nonvolatile memory 128 or the like by the CPU unit 104 ofthe PLC 100, a predetermined event (for example, execution of the DBconnection instruction) is generated. In the DB connection service, timesince transmission of the statement to the database device 400 untilreception of a response from the database device 400 is measured, andthe measurement result is stored as DB response time into the operationlog 184.

The storage to which the operation log 184 is written is not limited tothe memory card 172 but may be the main memory 126, the nonvolatilememory 128 (FIG. 2), or a storing device on the outside of the PLC 100.A storing device which can hold the operation logs 184 even in the casewhere the power of the PLC 100 is interrupted is preferable.

In such a system environment, the user can add a log output instructionto an arbitrary position in the user program 186 and can arbitrarilydelete a status acquisition instruction included in the user program186. It is now assumed that the user generates the user program 186including a status acquisition instruction (DB_GetConnectionStatus) asillustrated in FIG. 5 by the support device 300. The PLC 100 thenexecutes the user program 186, the operation log 184 is referred to inaccordance with the status acquisition instruction, and the user canread the DB response time 184J.

F. Operation Log 184

With reference to FIG. 6, the operation log 184 recorded by the PLC 100will be described. FIG. 6 is a diagram illustrating the operation log184. Logs recorded in the operation log 184 include an entry 184A, dateand a time 184B, a category 184C, a log name 184D, a result 184E, aconnection name 184F, a serial ID 184G, a table name 184H, and a DBresponse time 184J.

The data and time 184B indicates time at which a process as a logacquisition target occurs. The category 184C indicates the attribute ofa log. The log name 184D includes information by which the log can begrasped at a glance. The result 184E includes a code indicative of aresult of the process and includes, for example, information indicatingwhether connection to the database device 400 has succeeded or failed.The DB connection name 184F and the serial ID 184G are mainlyinformation regarding the DB connection and includes information of asetting which is used among preset connection settings. The table name184H includes information of identifying a database table connected bythe PLC 100. The DB response time 184J indicates time required forcommunication between the PLC 100 and the database device 400, which istime since the PLC 100 transmits a statement to the database device 400until a response is received as described above.

G. Process Procedure

Next, a process of outputting response time at the time of communicationwith the database device 400 in the PLC 100 in the embodiment to a logwill be described. FIG. 7 is a flowchart illustrating the procedure inthe PLC 100 in the embodiment and the procedure of the database device400. The steps shown in FIG. 7 are realized when the processor 120 inthe CPU unit 104 executes the user program 186 and the system program188. Although FIG. 9 shows an example where the user program 186 and thesystem program 188 are executed independently of each other, a singleprogram including both of the programs may be executed.

Referring to FIG. 7, regarding execution of the user program 186, theprocessor 120 loads the user program 186 prestored and executes theloaded user program 186 repeatedly in predetermined cycles. It isassumed that the user program 186 which is to be loaded is compiled andof an object format which can be executed. A source code generated bythe user may be loaded as it is, or may be complied with an intermediatecode, and the intermediate code may be loaded. In this case, whilecompiling the loaded code, the processor 120 executes the process. Thatis, the processor 120 executes a designated process while calling thesystem program 188 as necessary in accordance with an instructionincluded in the user program 186.

In step S101, when the processor 120 executes a process in accordancewith the instruction included in the user program 186 and executes aninstruction to access the database device 400, an access to the databasedevice 400 is executed by the DB access process program 192.

In step S201, the processor 120 executes an access to the databasedevice 400 by the DB access process program 192, and generates astatement (SQL statement) according to the instruction for accessing thedatabase device 400, which is included in the user program 186.

In step S203, the processor 120 transmits the generated SQL statement tothe database device 400.

In step S205, the processor 120 sets timeout time of communication withthe database device 400 and starts measurement of response time until aresponse from the database device 400 is received.

In step S401, the database device 400 receives the SQL statementtransmitted from the PLC 100 and executes the received SQL statement.

In step S403, the database device 400 sends an execution result of theSQL statement as a response to the PLC 100.

In step S207, the processor 120 receives from the database device 400 aresponse indicative of a result of execution of the SQL statement in thedatabase device 400 before the timeout time which is set forcommunication with the database device 400 elapses and obtains a resultof measurement of response time required until the response from thedatabase device 400 is received since the transmission of the SQLstatement.

In step S209, the processor 120 transfers the response from the databasedevice 400 from the DB access process program 192 to the user program186 and stores, as the DB response time 184J, response time measureduntil the response from the database device 400 is received into theoperation log 184.

In step S103, the processor 120 executes the user program 186 inaccordance with the execution result of the SQL statement.

Acquisition of Response Time from DB when Instruction Timeout Occurs

Referring now to FIG. 8, a method of storing response time in the casewhere timeout of an instruction occurs will be described. The processor120 calls the DB access process program 192 by an instruction includedin the user program 186 and performs a process for accessing to thedatabase device 400. It is assumed that a timeout occurs in theinstruction in the call of the DB access process program 192(instruction timeout). Also in the case where the execution is completedbecause the timeout occurs in the instruction included in the userprogram 186 (instruction timeout), the DB connection service itselfwaits for a response from the database device 400. In the case where thetime that the DB connection service waits for a response from thedatabase device 400 elapses (communication timeout), the DB connectionservice determines that the state of connection to the database device400 is abnormally disconnected. For example, in the case where acommunication failure or the like occurs in the communication pathbetween the PLC 100 and the database device 400, a communication timeoutoccurs.

In the following, a procedure taken in the case where an instructiontimeout occurs, and before a communication timeout occurs, the PLC 100receives a response indicative of a result of execution of an SQLstatement from the database device 400 will be described.

FIG. 8 is a diagram illustrating the procedure of the PLC 100 and theprocedure of the database device 400 when an instruction timeout occurs.

In step S101, the processor 120 executes a process in accordance with aninstruction included in the user program 186, executes an instructionfor accessing the database device 400, and executes an access to thedatabase device 400 by the DB access process program 192.

In step S201, the processor 120 executes an access to the databasedevice 400 by the DB access process program 192, and generates astatement (SQL statement) according to an instruction to access thedatabase device 400, which is included in the user program 186.

In step S203, the processor 120 transmits the generated SQL statement tothe database device 400.

In step S211, the processor 120 sets timeout time in communication withthe database device 400, starts measurement of response time until aresponse indicative of a result of execution of the SQL statement isreceived from the database device 400, and monitors whether or not atimeout (instruction timeout) occurs in execution of the instructionincluded in the user program 186.

In step S213, the processor 120 receives a response from the databasedevice 400 by the DB access process program 192 until the communicationtimeout occurs, and in the case where the instruction timeout occursuntil the communication timeout occurs, without storing the responsetime from the DB, transfers a notification indicative of the instructiontimeout from the DB access process program 192 to the user program 186.

In step S401, the database device 400 receives the SQL statementtransmitted from the PLC 100 and executes the received SQL statement.

In step S403, the database device 400 sends, as a response, theexecution result of the SQL statement to the PLC 100.

In step S215, the processor 120 receives a response indicative of theexecution result of the SQL statement from the database device 400,obtains a result of measurement of response time required to receive theresponse from the database device 400 since transmission of the SQLstatement, and stores the result as the DB response time 184J inassociation with time information into the operation log 184.

H. Modifications

As the foregoing embodiment, the example of measuring response timerequired to receive a response from the database device 400 after the DBaccess process program 192 transmits an SQL statement to the databasedevice 400 in order to store time until a response from the databasedevice 400 is received as the DB response time 184J into a log has beendescribed.

Another method of obtaining response time required to receive a responsefrom the database device 400 is as follows. For example, transmissiontime at which the processor 120 transmits an SQL statement to thedatabase device 400 and reception time at which the PLC 100 receives aresponse indicative of a result of execution of the SQL statement fromthe database device 400 are stored in a log. The PLC 100 may acquireresponse time from the database device 400 at the time of accessing thedatabase device 400 from the PLC 100 by obtaining the difference betweenthe transmission time and the reception time. The user may acquireresponse time from the database device 400 at the time of accessing thedatabase device 400 from the PLC 100 by generating the user programincluding the instruction of referring to the transmission time and thereception time included in the log by the support device 300 and causingthe PLC 100 to execute the user program.

FIG. 9 is a flowchart illustrating the procedure of the PLC 100 and theprocedure of the database device 400 in the modification.

In step S101, the processor 120 executes a process in accordance withthe instruction included in the user program 186, executes theinstruction for accessing the database device 400, and executes anaccess to the database device 400 by the DB access process program 192.

In step S201, the processor 120 executes an access to the databasedevice 400 by the DB access process program 192, and generates astatement (SQL statement) according to the instruction for accessing thedatabase device 400, included in the user program 186.

In step S203, the processor 120 transmits the generated SQL statement tothe database device 400.

In step S221, the processor 120 obtains time at which the SQL statementis transmitted and stores the fact of execution of the process oftransmitting the SQL statement in association with time information intoa log.

In step S401, the database device 400 receives the SQL statementtransmitted from the PLC 100 and executes the received SQL statement.

In step S403, the database device 400 sends, as a response, theexecution result of the SQL statement to the PLC 100.

In step S223, after transmission of the SQL statement to the databasedevice 400, the processor 120 sets timeout time of communication. Theprocessor 120 accepts a response from the database device 400 until thecommunication timeout occurs, and when a response from the databasedevice 400 is received, obtains reception time. The processor 120 storesthe fact of reception of the response result from the database device400 in association with the time information into a log.

In step S225, the processor 120 transfers the response from the databasedevice 400 to the user program 186 from the DB access process program192.

In step S103, the processor 120 executes the user program 186 inaccordance with the execution result of the SQL statement.

By the process, transmission time when the PLC 100 transmits the SQLstatement to the database device 400 and reception time when a responseis received from the database device 400 are stored in the log.Consequently, by obtaining the difference between the transmission timeand the reception time, the PLC 100 can obtain the DB response time184J.

I. Acquisition of Response Time from Database Device 400

The operation log 184 recorded by the PLC 100 is obtained, for example,by the support device 300, and the user can refer to the operation log184 by operating the support device 300. For example, the support device300 obtains the operation log 184 from the PLC 100 as follows. Thesupport device 300 performs communication with the PLC 100, reads theoperation log 184 from the memory by the system program 188 of the PLC100, and sends the read operation log 184 as a response from the PLC 100to the support device 300.

FIG. 10 is a flowchart illustrating a process to obtain the DB responsetime 184J of the support device 300.

In step S311, the support device 300 instructs the PLC 100 to obtain theoperation log 184.

In step S231, the processor 120 reads the operation log 184 from thememory by executing the system program 188.

In step S233, the processor 120 sends the operation log 184 read fromthe memory as a response to the support device 300 by execution of thesystem program 188.

In step S313, the support device 300 receives the operation log 184 fromthe PLC 100 and displays the received operation log 184 on the monitor314.

As another method, by causing a predetermined instruction to be includedin the user program, the operation log 184 may be read from the memory.The user can generate the user program 186 including a statusacquisition instruction (indicated as “DB_GetConnectionStatus” in theexample of FIG. 5) by operating the support device 300. By the statusacquisition instruction in the user program 186, the processor 120executes a process of reading the DB response time 184J while callingthe system program 188 or the DB access process program 192. By readingthe operation log 184 including the DB response time 184J by executionof the user program 186, for example, after execution of an arbitraryinstruction in the user program 186, the operation log 184 can beobtained, and the user can handle a cause such as a failure in thecommunication between the PLC 100 and the database device 400.

J. Example of User Interface in Support Device 300

FIGS. 11 and 12 are diagrams illustrating an example of a user interfaceprovided in the support device 300 according to the embodiment. Thesupport device 300 acquires the operation log 184 from the PLC 100 by,for example, the above-described process, and can display the acquiredoperation log 184 on the monitor of the support device 300.

FIG. 11 is a diagram illustrating an example of the user interface inthe case of displaying the operation log 184 including the DB responsetime 184J in the support device 300.

As illustrated in FIG. 11, in a display screen 380, the operation log184 including the DB response time 184J obtained by the support device300 is displayed as a list. In entries (381, 382, 383, 384, and 385) ofa response time log 388, various pieces of data included in theoperation log 184 (illustrated in FIG. 6) is displayed.

The support device 300 displays, for example, an acquisition button 390in the display screen 380. By accepting an input operation on theacquisition button 390 from the user, the operation log 184 includingthe DB response time 184J may be acquired from the PLC 100.

FIG. 12 is a diagram illustrating an example of displaying the DBresponse time 184J in the support device 300 in chronological order. Asillustrated in FIG. 11, the DB response time 184J is recorded inassociation with time information. Consequently, for example, in DBresponse time trend data 392, the support device 300 may display the DBresponse time 184J in chronological order in a graph format using the DBresponse time 184J as the vertical axis and using time as the abscissaaxis. In the example of FIG. 12, the connection name 184F is designatedby the user. A connection name display tab 393 indicates the connectionname designated by the user, and the DB response time 184J is displayedin chronological order.

In the example of FIG. 12, the DB response time 184J becomes long in acertain period but is relatively stable in the other time. Consequently,designers and the like can examine, for example, the possibility that adelay temporarily occurs in a communication in a communication pathbetween the PLC 100 and the database device 400. In the case where theDB response time 184J gradually increases with lapse of time, thedesigners and the like can examine, for example, the possibility that adelay occurs in the process of the database device 400 and theprocessing performance of the database device 400 is enhanced.

By employing a configuration as described above, the user can knowwhether the user program 186 is executed properly or not and can easilyspecify the cause when a failure occurs during execution of the userprogram 186. Accordingly, debugging in a program and checking ofsoundness can be performed efficiently. For example, also in the casewhere inconvenience such as a delay occurs in the process of the controlsystem including the PLC 100 and the database device 400, the cause canbe easily analyzed.

In the foregoing embodiment, the example was described in which, forexample, in the case where the PLC 100 receives a request to read theoperation log 184 from the support device 300 by the system program 188so that the support device 300 displays the operation log 184 on themonitor, the operation log 184 is read from a predetermined memory andsent as a response to the support device 300. Another method may beemployed such that, for example, the CPU unit 104 has an FTP (FileTransfer Protocol) server function, the CPU unit 104 is logged in by FTPclient software, and the FTP client software obtains the operation log184 by the FTP.

It is to be noted that the embodiments disclosed here are illustrativeand not restrictive in all of aspects. The scope of the presentinvention is defined by the scope of claims rather than by the abovedescription, and all changes that fall within the scope of claims orequivalence are intended to be included.

What is claimed is:
 1. A controller comprising: a communicationinterface configured to be connected to a database system; aninstruction executing unit configured to execute a user program forcontrolling a control object; and an access processing unit, at the timeof executing the user program comprising an access instruction to accessthe database system by the instruction executing unit, configured tocontrol an access to the database system via the communicationinterface, wherein the access processing unit comprises: a statementtransmitting unit configured to generate a statement according to theaccess instruction and transmit the generated statement to the databasesystem; and an acquiring unit configured to store into a memoryinformation indicative of time since transmission of the generatedstatement to the database system until reception of a response from thedatabase system.
 2. The controller according to claim 1, wherein theacquiring unit is configured to start measurement of response time bytransmitting the generated statement to the database system and storeinto the memory the information indicative of a result of themeasurement of the response time since transmission of the statement tothe database system until reception of a response from the databasesystem.
 3. The controller according to claim 1, wherein the acquiringunit is configured to record a transmission time at which the generatedstatement is transmitted to the database system, record a reception timeat which a response from the database system to the statement isreceived, acquire information indicative of a time until a response fromthe database system is received on the basis of the transmission timeand the reception time, and store the acquired information into thememory.
 4. The controller according to claim 1, wherein in the casewhere a normal response is received from the database system after thestatement is transmitted to the database system, the acquiring unitstores the response time into the memory.
 5. The controller according toclaim 1, wherein the instruction executing unit executes a user programcomprising a status acquisition instruction for acquiring informationindicative of time until a response from the database system isreceived, and the access processing unit sends the information stored inthe memory to the user program in response to the status acquisitioninstruction.
 6. The controller according to claim 1, further comprising:an input/output unit configured to transmit and receive data, whereinthe acquiring unit acquires information indicative of time until theresponse is received in association with time information each time thestatement is transmitted to the database system, the input/output unittransmits to an information processing apparatus the time informationand the information indicative of time until the response is received,in association with each other, and the information processing apparatusis connected to the controller.
 7. An information processing apparatusto be connected to a controller, wherein the controller is connected toa database system and comprises: a statement transmitting unitconfigured to, at the time of executing a user program comprising anaccess instruction for accessing the database system, generate astatement according to the access instruction, and transmit thegenerated statement to the database system; and an acquiring unitconfigured to store into a memory time information indicative of timesince the transmission of the generated statement to the database systemby the statement transmitting unit until reception of a response fromthe database system, and the information processing apparatus comprises:a reception processing unit configured to receive the time informationstored in the memory by the acquiring unit from the controller; and adisplay processing unit configured to display the time informationreceived by the reception processing unit on a monitor.
 8. Theinformation processing apparatus according to claim 7, wherein each timethe statement is transmitted to the database system, the acquiring unitof the controller stores into the memory information indicative of timeuntil the response is received, in association with time information,the reception processing unit of the information processing apparatusreceives from the controller information indicative of time until theresponse associated with the time information is received, and thedisplay processing unit displays the received time information inassociation with the time information.
 9. A computer-readable recordingmedium storing a computer program executable by a processor andconfigured to control operation of a controller, wherein the controllercomprises a communication interface configured to access a databasesystem, the processor, and a memory, and the program causes theprocessor to execute: a step of executing a user program to control acontrol object; a step of, at the time of executing the user programcomprising an access instruction to access the database system,generating a statement according to the access instruction andtransmitting the generated statement to the database system via thecommunication interface; a step of storing into the memory informationindicative of time since transmission of the generated statement to thedatabase system until reception of a response from the database system;and a step of outputting the stored information to the informationprocessing apparatus connected to the controller.
 10. A controllercomprising: a communication interface configured to be connected to adatabase system; a processor; and a memory, wherein the processorexecutes a user program to control a control object, at the time ofexecuting an access instruction to access the database system that isincluded in the user program, generates a statement according to theaccess instruction, transmits the generated statement to the databasesystem via the communication interface, and stores into the memoryinformation indicative of time until reception of a response from thedatabase system since the transmission.